package cn.stronglink.assetmanage.business.check.model;

import java.util.List;

import cn.stronglink.assetmanage.MyApplication;
import cn.stronglink.assetmanage.dao.AssetDao;
import cn.stronglink.assetmanage.dao.CheckDao;
import cn.stronglink.assetmanage.dao.DaoManager;
import cn.stronglink.assetmanage.entity.Asset;
import cn.stronglink.assetmanage.entity.Check;
import cn.stronglink.assetmanage.entity.Task;
import cn.stronglink.assetmanage.utils.Constants;

/**
 * 待入库数据操作
 * Created by chencongcong on 2018/6/14.
 */

public class WaitModel {

    //获取所有未入库的数据，根据表单名称去除重复数据 3为未入库
    public List<Check> getDataByOrderNoDistince() {
        List<Check> checkList = DaoManager.
                getDaoSession(MyApplication.APP_CONTEXT).getCheckDao().queryBuilder().distinct()
                .orderDesc(CheckDao.Properties.CreateTime).
                        where(CheckDao.Properties.Status.eq(Constants.STATUS_THREE)).
                        orderAsc(CheckDao.Properties.CreateTime).list();
        DaoManager.getDaoSession(MyApplication.APP_CONTEXT).clear();
        if (checkList != null) {
            return checkList;
        }
        return null;
    }

    /**
     * 根据表单号获得该表单中的未入库数据  3为未入库
     *
     * @param orderNo
     * @return
     */
    public List<Asset> getDataByOrderNo(String orderNo) {
        List<Asset> assetList = DaoManager.
                getDaoSession(MyApplication.APP_CONTEXT).getAssetDao().
                queryBuilder().where(AssetDao.Properties.OrderNo.eq(orderNo)).
                where(AssetDao.Properties.Status.eq(Constants.STATUS_THREE)).list();
        DaoManager.getDaoSession(MyApplication.APP_CONTEXT).clear();
        if (assetList != null) {
            return assetList;
        }
        return null;
    }

}
